package com.jt.controller;

import com.jt.pojo.ItemCatParam;
import com.jt.service.ItemCatParamService;
import com.jt.vo.SysResult;
import lombok.experimental.Accessors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/itemCatParam")
public class ItemCatParamController {

    @Autowired
    private ItemCatParamService itemCatParamService;
    /**
     * 实现商品分类参数的查询
     * URL: /itemCatParam/findItemCatParamListByType?itemCatId=564&paramType=1
     * 参数: itemCatId,paramType
     * 返回值: SysResult对象
     */
    @GetMapping("/findItemCatParamListByType")
    public SysResult findItemCatParamListByType(ItemCatParam itemCatParam){

        List<ItemCatParam> paramList =itemCatParamService.findItemCatParamListByType(itemCatParam);

        return SysResult.success(paramList);
    }
    @PostMapping("/addItemCatParam")
    @Transactional //事务控制
    public SysResult addItemCatParam(@RequestBody ItemCatParam itemCatParam){
        itemCatParamService.addItemCatParam(itemCatParam);

        return SysResult.success();
    }
    @PutMapping("/updateItemCatParam")
    public SysResult updateItemCatParam(@RequestBody ItemCatParam itemCatParam){
        itemCatParamService.updateItemCatParam(itemCatParam);
        return SysResult.success();
    }
    @DeleteMapping("/deleteItemCatParamById")
    public SysResult deleteItemCatParamById(Integer paramId){
        itemCatParamService.deleteItemCatParamById(paramId);
        return SysResult.success();
    }
}
